feat: add BedrockTransport + wire build_kwargs#13467
feat: add BedrockTransport + wire build_kwargs#13467kshitijk4poor wants to merge 1 commit intomainfrom
Conversation
31e0516 to
937ff26
Compare
Add BedrockTransport wrapping agent/bedrock_adapter.py behind the ProviderTransport ABC. Fourth and final transport. Wire ALL transport methods to production paths in run_agent.py: - build_kwargs: _build_api_kwargs bedrock branch (L6713) - normalize_response: main normalize loop, new bedrock_converse branch (handles both raw boto3 dicts and already-normalized SimpleNamespace) - validate_response: response validation, new bedrock_converse branch - finish_reason: new bedrock_converse branch in finish_reason extraction The truncation path (L9588) intentionally groups bedrock with chat_completions — both have the same response.choices shape because normalize_converse_response runs at the dispatch site. 17 new tests. 231 bedrock/converse/transport tests pass (0 failures). PR 6 of the provider transport refactor.
937ff26 to
f56c373
Compare
Fourth and final transport — completes the transport layer with all four api_modes covered. Wraps agent/bedrock_adapter.py behind the ProviderTransport ABC, handles both raw boto3 dicts and already-normalized SimpleNamespace. Wires all transport methods to production paths in run_agent.py: - build_kwargs: _build_api_kwargs bedrock branch - validate_response: response validation, new bedrock_converse branch - finish_reason: new bedrock_converse branch in finish_reason extraction Based on PR #13467 by @kshitijk4poor, with one adjustment: the main normalize loop does NOT add a bedrock_converse branch to invoke normalize_response on the already-normalized response. Bedrock's normalize_converse_response runs at the dispatch site (run_agent.py:5189), so the response already has the OpenAI-compatible .choices[0].message shape by the time the main loop sees it. Falling through to the chat_completions else branch is correct and sidesteps a redundant NormalizedResponse rebuild. Transport coverage — complete: | api_mode | Transport | build_kwargs | normalize | validate | |--------------------|--------------------------|:------------:|:---------:|:--------:| | anthropic_messages | AnthropicTransport | ✅ | ✅ | ✅ | | codex_responses | ResponsesApiTransport | ✅ | ✅ | ✅ | | chat_completions | ChatCompletionsTransport | ✅ | ✅ | ✅ | | bedrock_converse | BedrockTransport | ✅ | ✅ | ✅ | 17 new BedrockTransport tests pass. 117 transport tests total pass. 160 bedrock/converse tests across tests/agent/ pass. Full tests/run_agent/ targeted suite passes (885/885 + 15 skipped; the 1 remaining failure is the pre-existing test_concurrent_interrupt flake on origin/main).
|
Salvaged and merged via #13814 onto current main (commit 57411fc). Your authorship is preserved on the merge commit. One adjustment from the original: the main normalize loop does NOT add a bedrock_converse branch. Bedrock's With this merged, Cycle 1 transport coverage is complete — all four api_modes (anthropic_messages, codex_responses, chat_completions, bedrock_converse) now have transports wired to build_kwargs + validate_response + normalize_response. Thanks for the substantive work across the series (PRs 2-6). |
Summary
PR 6 of the provider transport refactor (PRs 1-5: #12975, #13073, #13366, #13430, #13447).
Fourth and final transport — completes the transport layer with all 4 api_modes covered. All transport methods wired to production paths.
What ships
agent/transports/bedrock.py— BedrockTransport (155 lines)All transport methods wired:
build_kwargs()_build_api_kwargsbedrock branch (L6713)normalize_response()bedrock_conversebranch (L10828)validate_response()bedrock_conversebranch (L9389)finish_reasonbedrock_conversebranch (L9559)convert_messages()/convert_tools()build_kwargs()normalize_response()handles two shapes: raw boto3 dicts (from direct converse calls) and already-normalized SimpleNamespace with .choices (from the dispatch site at L5169).The truncation path (L9588) intentionally groups bedrock with chat_completions — both have the same
response.choicesshape becausenormalize_converse_responsealready runs at the dispatch site.Transport coverage — complete
Test plan